export const formattedValue = (num: number | string, min?: number, max?: number, precision?: number) => {
  let value = Number(num);
  if (isNaN(value)) {
    return '';
  }
  if (min && value < min) {
    value = min;
  }
  if (max && value > max) {
    value = max;
  }
  if (precision !== undefined) {
    return value.toFixed(precision);
  }
  return value.toString();
};
